import axios from "axios";

export const getUserBalance = (userId) => {
    return axios.get('/user/balance', {params: {userId}}).then(res => res.data)
/*  return new Promise((resolve) => {
    console.log('start getting task user balance');
    console.log(userId)
    setTimeout(() => {
      console.log('user balance got!');
      resolve({
        "code": 200,
        "msg": "string",
        "data": 200
      })

    }, 3000)
  })*/
}

export const getUserTransactionDetails = (userId, startTime, endTime) => {
  return axios.get(
      '/user/transactionDetails',
      {
        params: {userId, startTime: +startTime, endTime: (+endTime + 24 * 60 * 60 * 1000)}
      }
  ).then(res => res.data);
/*  return new Promise((resolve) => {
    console.log('start getting user transaction details');
    console.log(userId)
    setTimeout(() => {
      console.log('user transaction details got!');
      resolve({
        "code": 200,
        "msg": "string",
        "data": [
          {
            "time": "2022-10-08T06:17:44.237Z",
            "type": "type",
            "in": 0,
            "out": 100,
            "balance": 100,
            "remark": "remark",
            "transactionNumber": "123"
          },
          {
            "time": "2022-10-08T06:17:44.237Z",
            "type": "type",
            "in": 0,
            "out": 150,
            "balance": 250,
            "remark": "remarkdsaf",
            "transactionNumber": "123345"
          }
        ]
      })

    }, 3000)
  })*/
}

export const sendMessage = (messageFrom) => {
    return axios.post(
        '/user/sendMessage',
        messageFrom
    ).then(res => res.data);

    /*return new Promise(resolve =>  {
        console.log('start send message');
        console.log(messageFrom);
        setTimeout(() => {
            console.log('message sent');
            resolve({
                "code": 200,
                "msg": "string",
                "data": {}
            })
        }, 3000)
    })*/
}
